use "/Users/jrthornton/Desktop/Replication/anes_timeseries_2012_slim.dta" , clear

set more off

gen year = 2012
* weight
gen w = weight_full
******************
* SOPHISTICATION *
******************
* Created with three items: knowledge, interest, and involvement
		
* Knowledge (DONE)
gen interviewer_assesment = iwrobspre_levinfo
recode interviewer_assesment (1=.) (2=.)
replace interviewer_assesment = interviewer_assesment-2
revrs interviewer_assesment , replace

* Interest (DONE)
gen interest = interest_following
recode interest (1=.) (2=.)
replace interest = interest-2
revrs interest , replace

* Involvement 
*Attendance at political events*
*Note: This value is recoded so that higher values reflect greater* 
*political involvement*

gen Attendm = mobilpo_rally
replace Attendm = . if Attendm<5
replace Attendm = Attendm-5
recode Attendm (0=1) (1=0)
label var Attendm "Attend a Political Event"
label define Attendancem 0 "No" 1 "Yes" , replace
label values Attendm Attendancem

*Work for a political candidate*
*Note: This value is recoded so that higher values reflect greater* 
*political involvement*

gen Workm = mobilpo_otherwork
replace Workm = . if Workm<5
replace Workm = Workm-5
recode Workm (0=1) (1=0)
label var Workm "Work for a Political Candidate"
label define Workedm 0 "No" 1 "Yes", replace
label values Workm Workedm

*Political expression in the form of a campaign button or sticker*
*Note: This value is recoded so that higher values reflect greater* 
*political involvement*

gen Displaym = mobilpo_sign
replace Displaym = . if Displaym<5
replace Displaym = Displaym-5
recode Displaym (0=1) (1=0)
label var Displaym "Display a Campaign Button or Sticker"
label define Displaypoliticsm 0 "No" 1 "Yes" , replace
label values Displaym Displaypoliticsm

*Donation to a political candidate*
*Note: This value is recoded so that higher values reflect greater* 
*political involvement*

gen Donatecm = mobilpo_ctbcand
replace Donatecm = . if Donatecm<5
replace Donatecm = Donatecm-5
recode Donatecm (0=1) (1=0)
label var Donatecm "Donate money to a political candidate"
label define Donatecandidatem 0 "No" 1 "Yes" , replace
label values Donatecm Donatemoneycm

*Donation to a political party*
*Note: This value is recoded so that higher values reflect greater* 
*political involvement*

gen Donatepm = mobilpo_ctbpty
replace Donatepm = . if Donatepm<5
replace Donatepm = Donatepm-5
recode Donatepm (0=1) (1=0)
label var Donatepm "Donate money to a political party"
label define Donatepartym 0 "No" 1 "Yes" , replace
label values Donatepm Donatepartym

*Did R talk to anyone about voting for or against cand or pty to a political party*
*Note: This value is recoded so that higher values reflect greater* 
*political involvement*

gen Talk = mobilpo_rmob
replace Talk = . if Talk<5
replace Talk = Talk-5
recode Talk (0=1) (1=0)
label var Talk "Talk to to anyone for or against"
label define Talkm 0 "No" 1 "Yes" , replace
label values Talk Talkm



gen involvement=( Attendm+ Workm+ Displaym+ Donatecm+ Donatepm+ Talk)

gen house = knowl_housemaj
recode house (1=.) (2=0) (3=.) (4=0) (5=0) (6=1)

*******************
* EQUALITARIANISM *
*******************
* Scale created from six tiems
	* 1. 'Our society should do whatever is necessary to make sure that 
			* everyone has an equal opportunity to succeed.'
	* 2. 'We have gone too far in pushing equal rights in this country.'
	* 3. 'One of the big problems in this country is that we don't give
			* everyone an equal chance.'
	* 4. 'It is not really that big a problem if some people have more of a
			* chance in life than others.'
	* 5. 'The (2004: This_ country would be better off if we worried less
			* about how equal people are.'		
	* 6. 'If people were treated more equally in this country we would have
			* many fewer problems.'

gen equality1 = egal_equal
replace equality1 = . if equality1<5
replace equality1 = equality1 - 4
recode equality1 (1=5) (5=1) (2=4) (4=2)

*gen equality2 = VCF9014 (not asked in 2016)
*recode equality2 (8=.) (9=.)

*gen equality3 = VCF9015 (not asked in 2016)
*recode equality3 (8=.) (9=.)
*recode equality3 (1=5) (5=1) (2=4) (4=2)

gen equality4 = egal_notbigprob
replace equality4 = . if equality4<5
replace equality4 = equality4 - 4

gen equality5 = egal_worryless
replace equality5 = . if equality5<5
replace equality5 = equality5 - 4

gen equality6 = egal_fewerprobs
replace equality6 = . if equality6<5
replace equality6 = equality6 - 4
recode equality6 (1=5) (5=1) (2=4) (4=2)

gen equality = (equality1 + equality4 + equality5 ///
	+ equality6)/4
su equality, meanonly
replace equality = (equality- r(min)) /(r(max) - r(min))


*******************
* GROUP VARIABLES *
*******************
* Race
* White
gen race = dem_raceeth_x 
replace race = race-1
tab race
recode race (1=1) (2=2) (3=4)  (4=4) (5=3) (6=4) (0=.)
label define racelabel 1 "White" 2 "Black" 3 "Hispanic" 4 "Other" 
label values race racelabel  
*1. White non-Hispanic
*2. Black non-Hispanic
*3. Hispanic
*4. Other or multiple races, non-Hispanic




*********************
* CONTROL VARIABLES *
*********************
gen gender = gender_respondent_x
recode gender (-9=.) (3=.)
gen sex = gender -1 
label define genderlab 0 "0. Male" 1 "1. Female" , replace
label values sex genderlab

gen age = dem_age_r_x
replace age = . if age<17

gen educ = dem_edu
recode edu (1=.)
replace edu = edu - 2
recode edu (1=1) (2=1) (3=1) (4=1) (5=2) (6=2) (7=2) (8=2) (9=3) (11=4) ///
	(10=5) (12=5) (13=6) (13=7) (14=7) (15=7) (16=7) (90=3) (95=.) (-9=.)
label define edulab 1 "1. 8 grades or less" 2 "2. 9-12 grades" 3 "3. High school" ///
	4 "4. HS + non-academic training" 5 "5. Some college" 6 "7. BA" 7 "7. Advanced" , replace
label values edu edulab

gen income	= incgroup_prepost_x
recode income (1 = .) (2=.)
replace income =incgroup_prepost_x - 4

* Ideology
gen ideology = libcpre_self if libcpre_self
replace ideology = . if ideo<4
replace ideology = ideology-3

* Partisanship
gen pid = pid_x 
replace pid = . if pid == 1
replace pid = pid -1
# delimit ; 
label define pid_label        
		1 "Strong Democrat" 
        2 "Weak Democrat" 
        3 "Independent - Democrat" 
        4 "Independent - Independent" 
        5 "Independent - Republican" 
		6 "Weak Republican" 
        7 "Strong Republican"
		,
		replace
;
# delimit cr
label values pid pid_label

gen pidi = abs(pid-4)
# delimit ; 
label define pidi_label        
		0 "Independent" 
		1 "Weak partisan" 
        2 "Partisan" 
		3 "Strong partisan" 
;
# delimit cr
label values pidi pidi_label

gen democrat = 1 if pid<4


gen party = 0 if pid<4
replace party = 1 if pid==4
replace party = 2 if pid>4
label define partylabel 0 "Democrat" 1 "Independent" 2 "Republican" 
label values party partylabel



* Gay issues

gen gay_adopt = gayrt_adopt	
recode gay_adopt (1=.) (2=.) (3=1) (4=0)


gen gay_discrimination = gayrt_discrev_x	
replace gay_discrimination = . if gay_discrimination<4
replace gay_discrimination = gay_discrimination-3
recode gay_discrimination (1=4) (2=3) (3=2) (4=1)

gen gay_marriage = gayrt_marry	
replace gay_marriage = . if gay_marriage<3
replace gay_marriage = gay_marriage - 2
recode gay_marriage (1=3) (3=1)



gen sexual_orientation =  orientn_rgay
recode sexual_orientation (1=.) (2=.) (3=0) (4=1) (5=2)
label define orientation_label 0 "Straight" 1 "Gay" 2 "Bisexual" 
label values sexual_orientation orientation_label
gen gay = sexual_orientation
recode gay (2=1)
label define gay_label 0 "Straight" 1 "Gay or bisexual" 
label values gay gay_label

gen therm_gays = ftgr_gay
replace therm_gays = . if therm_gays<0

*est drop _all
*svy: reg gay_issues c.soph_irt##i.gay pidi age income educ i.sex i.race equality_irt if party==0
*margins , at(soph=(0(.2)1) gay=0) post noatlegend
*est sto straight
*svy: reg gay_issues c.soph_irt##i.gay pidi age income educ i.sex i.race equality_irt if party==0
*margins , at(soph=(0(.2)1) gay=1) post noatlegend
*est sto gay

*# delimit ;
*	coefplot 
*	(gay , msymbol(diamond) mcolor(black)) 
*	(straight , msymbol(square) mcolor(black)) 
*	,	at 	
*	lwidth(*1) 
*	ciopts(lcolor(black)) 
*	ylab(, format(%03.1f))
*	xlab(, format(%03.1f))
*	ytitle("Support for laws to protect gays and  lesbians" 
*	"against job discrimination")
*	xtitle(Sophistication) 
*	legend(order(2 "Gay" 4 "Straight") pos(6) col(3)  
*		region(lcolor(none)))
*	aspect(1)
*    ;
*# delimit cr









keep equality1 equality4 equality5 equality6 interviewer_assesment  interest  involvement gay_discrimination gay_marriage gay_adopt gay year  income party race gay age ideo sex educ pidi therm_gays house w
save "/Users/jrthornton/Desktop/Replication/2012_combined.dta" , replace



